
package com.sausageking.auth;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class UserLoginUtil {

  // DO NOT CHANGE THIS METHOD, OTHERWISE, THE PERSISTED PASSWORD HASH WILL NOT BE VERIFIED.
  public static String generatePasswordHash(String password)
      throws UnsupportedEncodingException {
    MessageDigest sha;
    byte[] bytesOfMessage = password.getBytes("UTF-8");
    try {
      sha = MessageDigest.getInstance("SHA");
      byte[] digest = sha.digest(bytesOfMessage);
      return new String(digest);
    } catch (NoSuchAlgorithmException e) {
      throw new RuntimeException(e);
    }
  }
}
